import 'package:flutter/material.dart';
import 'package:provider/provider.dart';
import 'package:smartidea_shop/utils/base.dart';
import '../router/routes.dart';
import '../provider/base.dart';

class App extends StatefulWidget {
  const App({Key? key}) : super(key: key);

  @override
  _AppState createState() => _AppState();
}

class _AppState extends State<App> {
  @override
  void initState() {
    ShopRouter.init();
    super.initState();
  }

  @override
  void dispose() {
    ShopRouter.destory();
    super.dispose();
    // Widget彻底销毁时调用
  }

  @override
  Widget build(BuildContext context) {
    String _initialRoute =
        Provider.of<BaseProvider>(context, listen: false).state.navigateTo!;
    print('_initialRoute$_initialRoute');
    return MaterialApp(
      title: 'smartidea',
      debugShowCheckedModeBanner: false,
      theme: ThemeData(
        primarySwatch: Colors.red,
        primaryColor: HexColor('D7E600'),
      ),
      initialRoute: _initialRoute,
      onGenerateRoute: ShopRouter.generator,
    );
  }
}
